package cn.hanyx.test.sort;

import java.util.*;
import java.util.stream.Stream;

/**
 * SortDemo
 *
 * @author hanyx
 * @date 2020/08/18
 */
public class SortDemo {
    public static void main(String[] args) {
        List<Integer> list = new ArrayList<>();
        list.add(5);
        list.add(3);
        list.add(1);
        System.out.println(list);
        Collections.sort(list, new Comparator<Integer>() {
            public int compare(Integer o1, Integer o2) {
//                return o1.compareTo(o2);
                System.out.println("o1: " + o1 + ", o2: " + o2);
                return -1;
            }
        });
        System.out.println(list);

        Optional<Integer> result = Stream.of("f", "ba", "hello")
                .map(s -> s.length())
                .filter(l -> l <= 3)
                .max(Comparator.naturalOrder());
        System.out.println(result);
    }
}
